do 2_topreform.do
do 3_top1.do

use factor centila nivel renta cral_sty using "D:\work\uvigo\research\top_income_tax\do_files\1_stylized_progressive_tax.dta", clear

forvalues type=1/3{
nois disp "Reform type " `type'`type'
local tme_rich=0
local points=1
	while `tme_rich'<.5{
	quiet topreform renta cral_sty `points' `type' `type'
	gen double tax_new_`points'`type'`type'=tax_new
	gen double net_income_new_`points'`type'`type'=net_income_new
	sum tax_new [iw=factor] if nivel==1
	local tax=r(sum)
	sum renta [iw=factor] if nivel==1
	local income=r(sum)
	local tme_rich=`tax'/`income'
	nois disp `points' " => " `tme_rich'
	local points=`points'+1
	}
}

save 4_reforms.dta, replace

nois top1 gross_income tax_old
forvalues points=1/9{
nois top1 gross_income tax_new_`points'22
}
